package com.vnp.cooking.adapter;

import java.util.ArrayList;

import com.vnp.cooking.R;
import com.vnp.cooking.adapter.ListNguyenlieuAdapter.ViewHolder;
import com.vnp.cooking.bean.ObjBST;
import com.vnp.cooking.utils.Utils;

import android.content.Context;
import android.graphics.Typeface;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.view.animation.Animation;
import android.view.animation.AnimationUtils;
import android.widget.ArrayAdapter;
import android.widget.TextView;

public class ThemBoSuuTapAdapter extends ArrayAdapter<ObjBST>{
	
	Context context;
	ArrayList<ObjBST> objBSTs;
	
	public ThemBoSuuTapAdapter(Context context,ArrayList<ObjBST> objBSTs) {
		super(context, R.layout.list_item_bosuutap, objBSTs);
		this.context = context;
		this.objBSTs = objBSTs;
	}

	@Override
	public int getCount() {
		return objBSTs.size();
	}

	@Override
	public View getView(int position, View v, ViewGroup parent) {
		ViewHolder holder = null;
		if (v == null) {
			LayoutInflater inflater = LayoutInflater.from(getContext());
			v = inflater.inflate(R.layout.list_item_bosuutap, parent, false);
			
			holder = new ViewHolder();
			
			holder.txtTenBST = (TextView) v.findViewById(R.id.txt_ten_bosuutap);
			holder.slMonAnTrongBST = (TextView) v.findViewById(R.id.txt_sl_monan_bst);
			
			
			holder.txtTenBST.setTypeface(Utils.getTypefaceRegular(context), Typeface.BOLD);
			holder.slMonAnTrongBST.setTypeface(Utils.getTypefaceRegular(context), Typeface.BOLD);
			
			v.setTag(holder);
		} else {
			holder = (ViewHolder)v.getTag();
		}
		// Animation list
		/*Animation animation = AnimationUtils.loadAnimation(context,R.anim.animation_list_text);
		v.startAnimation(animation);*/
		// set gia tri
		holder.txtTenBST.setText(objBSTs.get(position).getName());
		holder.slMonAnTrongBST.setText("("+""+objBSTs.get(position).getSoluong()+ ")");
		
		return v;
	}
	
	
	class ViewHolder {
		TextView txtTenBST;
		TextView slMonAnTrongBST;
	}
	

}
